﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
    <script src="~/js/moment.js"></script>
</head>
<body>

    <form class="layui-form layui-col-space16" style="width:100%">
        <div class="layui-row">
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>工单编码:</b> </div>
                    <input type="text" id="ProductionWorkOrdersNoSe" value="" placeholder="请输入工单编码" class="layui-input" lay-affix="clear">
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>工单名称:</b> </div>
                    <input type="text" id="ProductionWorkOrdersNameSe" placeholder="请输入工单名称" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>来源单据:</b> </div>
                    <div class="layui-input-inline">
                        <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="" title="全部" checked>
                        <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="客户订单" title="客户订单">
                        <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="库存备货" title="库存备货">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>产品编号:</b> </div>
                    <input type="text" id="ProductsNoSe" placeholder="请输入产品编号" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>产品名称:</b> </div>
                    <input type="text" id="ProductsNameSe" placeholder="请输入产品名称" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>客户编码:</b> </div>
                    <input type="text" id="ClientNoSe" placeholder="请输入客户编码" lay-affix="clear" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>客户名称:</b> </div>
                    <input type="text" id="ClientNameSe" placeholder="请输入客户名称" lay-affix="clear" class="layui-input">
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>工单类型:</b> </div>
                    <div class="layui-input-inline">
                        <select id="TicketsTypeSe" lay-filter="aihao">
                            <option value=""></option>
                            <option value="自产">自产</option>
                            <option value="外协">外协</option>
                            <option value="外购">外购</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-col-sm4">
                <div class="layui-input-group">
                    <div class="layui-input-prefix"><b>需求日期:</b> </div>
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-date"></i>
                        </div>
                        <input type="text" id="DemandDateSe" readonly placeholder="请选择需求日期" class="layui-input demo-table-search-date">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-btn-container layui-col-xs12">
            <button class="layui-btn" lay-submit lay-filter="demo-table-search">查询</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button type="button" class="layui-btn layui-btn-primary" lay-on="test-page-custom">
                <span class="layui-badge-dot"></span>新增
            </button>
            <button type="button" class="layui-btn demo-class-accept" lay-options="{accept: 'file'}">
                <i class="layui-icon layui-icon-upload"></i>
                上传文件
            </button>
        </div>
    </form>


    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
        </div>
    </script>
    <table class="layui-hide" id="ID-table-demo-search" lay-filter="ID-table-demo-search"></table>
    <script type="text/html" id="toolDemo">
                <div class="layui-clear-space">
          {{#  if(d.state === '草稿'){ }}
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs" lay-event="delect">删除</a>
            <a class="layui-btn layui-btn-xs" lay-event="Preview">预览</a>
          {{#  } else { }}
            <a class="layui-btn layui-btn-xs" lay-event="Preview">预览</a>
          {{#  } }}
        </div>
    </script>
    <div id="demo-laypage-all"></div>
    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
    <script>
        var $ = layui.$;
        var layer = layui.layer;
        var form = layui.form;
        function AddThis(val, name) {
            $("[name='CustomerNo']").val(val);
            $("[name='Customername']").val(name);
            form.render();
            layer.close(layer.index); // 关闭当前最新弹层
        }
        function ChoosePro(val, name, Unit, Danw) {
            $("[name='ProductsNo']").val(val)
            $("[name='ProductsName']").val(name)
            $("[name='Specification']").val(Unit)
            $("[name='Units']").val(Danw)
            form.render();
            layer.close(layer.index);
        }
        layui.use(function () {
            var table = layui.table;
            var $ = layui.$;
            var form = layui.form;
            var laydate = layui.laydate;
            var util = layui.util;
            var layer = layui.layer;
            var laypage = layui.laypage;
            var tree = layui.tree;
            var upload = layui.upload;
            //新增弹出层事件
            util.on('lay-on', {
                'test-page-custom': function () {
                    layer.open({
                        type: 1,
                        area: ['1000px', '700px'],
                        resize: false,
                        shadeClose: true,
                        title: '添加生产工单',
                        content: `<form class="layui-form" action="">
                                                                                                                                                                   <div class="layui-form-item">
                                                                                                                                                                       <label class="layui-form-label"><span style="color:red">*</span>工单编号</label>
                                                                                                                                                                       <div class="layui-input-inline">
                                                                                                                                                                            <input width="100px" type="text" name="ProductionWorkOrdersNo" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                                                       <div class="layui-input-suffix">
                                                                                                                                                                           <div class="layui-input-inline">
                                                                                                                                                                              <div class="layui-input-group">
                                                                                                                                                                                      <label class="layui-form-label">自动生成</label>
                                                                                                                                                                              <input type="checkbox" name="open" lay-skin="switch" lay-filter="switchTest" title="ON|OFF">

                                                                                                                                                                              </div>
                                                                                                                                                                           </div>
                                                                                                                                                                       </div>
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div class="layui-form-item">
                                                                                                                                                                     <label class="layui-form-label"><span style="color:red">*</span>工单名称</label>
                                                                                                                                                                        <div class="layui-input-inline">
                                                                                                                                                                            <input type="text" name="ProductionWorkOrdersName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div class="layui-form-item layui-col-md4">
                                                                                                                                                                     <label class="layui-form-label"><span style="color:red">*</span>来源类型</label>
                                                                                                                                                                     <div class="layui-input-block">
                                                                                                                                                                         <input type="radio" lay-filter="demo-radio-filter" name="Source" value="客户订单" title="客户订单">
                                                                                                                                                                         <input type="radio" lay-filter="demo-radio-filter" name="Source" value="库存备货" title="库存备货">
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div id="thisOrders"></div>
                                                                                                                                                                   <div class="layui-form-item layui-col-xs6">
                                                                                                                                                                     <label class="layui-form-label"><span style="color:red">*</span>工单类型</label>
                                                                                                                                                                      <div class="layui-input-block">
                                                                                                                                                                        <select name="TicketsType" lay-filter="aihao">
                                                                                                                                                                          <option value=""></option>
                                                                                                                                                                          <option value="自产">自产</option>
                                                                                                                                                                          <option value="外协">外协</option>
                                                                                                                                                                          <option value="外购">外购</option>
                                                                                                                                                                        </select>
                                                                                                                                                                      </div>
                                                                                                                                                                   </div>
                                                                                                                                                                    <div class="layui-form-item layui-col-md6">
                                                                                                                                                                      <label class="layui-form-label"><span style="color:red">*</span>产品编号</label>
                                                                                                                                                                      <div class="layui-input-group">
                                                                                                                                                                           <input type="text" name="ProductsNo" placeholder="带任意前置和后置内容" class="layui-input">
                                                                                                                                                                       <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                                                                                                                                                                            <i class="layui-icon layui-icon-search" lay-on="test-iframe-Manage"></i>
                                                                                                                                                                       </div>
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                    <div class="layui-col-md6">
                                                                                                                                                                      <label class="layui-form-label"><span style="color:red">*</span>产品名称</label>
                                                                                                                                                                      <div class="layui-input-inline">
                                                                                                                                                                            <input type="text" name="ProductsName"  placeholder="" autocomplete="off" class="layui-input" disabled>
                                                                                                                                                                      </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div class="layui-form-item layui-col-md6">
                                                                                                                                                                      <label class="layui-form-label">规格型号</label>
                                                                                                                                                                      <div class="layui-input-group">
                                                                                                                                                                            <input type="text" name="Specification" placeholder="带任意前置和后置内容" class="layui-input" disabled>
                                                                                                                                                                      </div>
                                                                                                                                                                   </div>
                                                                                                                                                                    <div class="layui-col-md6">
                                                                                                                                                                      <label class="layui-form-label">单位</label>
                                                                                                                                                                      <div class="layui-input-inline">
                                                                                                                                                                         <input type="text" name="Units"  placeholder="个" autocomplete="off" class="layui-input" disabled>
                                                                                                                                                                      </div>
                                                                                                                                                                   </div>
                                                                                                                                                                        <div class="layui-form-item layui-col-xs4">
                                                                                                                                                                        <div class="layui-block">
                                                                                                                                                                        <label class="layui-form-label"><span style="color:red">*</span>工单数量</label>
                                                                                                                                                                        <div class="layui-input-inline" style="width: 100px;">
                                                                                                                                                                           <input type="number" name="TicketsNum" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number">
                                                                                                                                                                        </div>
                                                                                                                                                                      </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div class="layui-col-xs4">
                                                                                                                                                                       <div class="layui-input-group">
                                                                                                                                                                           <div class="layui-input-prefix"><span style="color:red">*</span>需求日期</div>
                                                                                                                                                                           <div class="layui-input-wrap">
                                                                                                                                                                               <div class="layui-input-prefix">
                                                                                                                                                                                   <i class="layui-icon layui-icon-date"></i>
                                                                                                                                                                               </div>
                                                                                                                                                                               <input type="text" name="DemandDate" readonly placeholder="请选择需求日期" class="layui-input demo-table-search-date">
                                                                                                                                                                           </div>
                                                                                                                                                                       </div>
                                                                                                                                                                   </div>
                                                                                                                                                                     <div class="layui-col-xs4">
                                                                                                                                                                     <label class="layui-form-label">批次号</label>
                                                                                                                                                                        <div class="layui-input-inline">
                                                                                                                                                                           <input type="text" name="BatchNo"  placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div id="thisClient"></div>
                                                                                                                                                                   <div class="layui-form-item layui-form-text">
                                                                                                                                                                     <label class="layui-form-label">备注</label>
                                                                                                                                                                     <div class="layui-input-block">
                                                                                                                                                                         <textarea placeholder="请输入内容" name="Remark" class="layui-textarea"></textarea>
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                   <div class="layui-form-item">
                                                                                                                                                                     <div class="layui-input-block">
                                                                                                                                                                       <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                                                                                                                                                                       <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                                                                                                                                                     </div>
                                                                                                                                                                   </div>
                                                                                                                                                                </form>`,
                        success: function () {
                            // 对弹层中的表单进行初始化渲染
                            // 日期
                            laydate.render({
                                elem: '.demo-table-search-date'
                            });
                            form.render();
                            // 表单提交事件
                            form.on('submit(demo1)', function (data) {
                                var field = data.field

                                let obj = {
                                    ProductionWorkOrdersNo: $("[name='ProductionWorkOrdersNo']").val(),
                                    ProductionWorkOrdersName: $("[name='ProductionWorkOrdersName']").val(),
                                    Source: $("[name='Source']:checked").val(),
                                    TicketsType: $("[name='TicketsType']").val(),
                                    OrderNumber: $("[name='OrdersNo']").val(),
                                    ProductsNo: $("[name='ProductsNo']").val(),
                                    TicketsNum: $("[name='TicketsNum']").val(),
                                    Remark: $("[name='Remark']").val(),
                                    DemandDate: $("[name='DemandDate']").val(),
                                    BatchNo: $("[name='BatchNo']").val(),
                                    CustomerNo: $("[name='CustomerNo']").val(),
                                    Pid: 0
                                }
                                console.log(obj)
                                $.ajax({
                                    url: '@ViewBag.FoundationWrite' + "/api/WorkOrder/ProductionCreateOrUpdate",
                                    data: JSON.stringify(obj),
                                    type: "post",
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: function (res) {
                                        console.log(123, res);
                                        var mesg = "";
                                        if (res.code > 0) {
                                            if (obj.Pid == 0) {
                                                mesg = "添加";
                                            }
                                            layer.msg(mesg+'成功', {
                                                offset: '6px'
                                            });
                                            getTable(1, 2);
                                        }
                                        else {
                                            alert('提交失败')
                                        }

                                    }
                                })
                                // …
                                return false; // 阻止默认 form 跳转
                            });
                        }
                    });
                },
                'test-iframe-Client': function () {
                    layer.open({
                        type: 1,
                        area: ['900px', '600px'],
                        resize: false,
                        shadeClose: true,
                        title: '',
                        content: `<h2 style="text-align:center">客户选择</h2>
                                                                                                  <form class="layui-form" action="">
                                                                                                      <div class="layui-form">
                                                                                                          <div class="layui-form-item">
                                                                                                              <div class="layui-input-group">
                                                                                                                  <div class="layui-input-prefix">
                                                                                                                      客户编码
                                                                                                                  </div>
                                                                                                                  <div>
                                                                                                                      <input id="ClientNo" type="text" placeholder="请输入客户编码" class="layui-input">
                                                                                                                  </div>

                                                                                                                  <div class="layui-input-prefix" style="left:50px">
                                                                                                                      客户名称
                                                                                                                  </div>
                                                                                                                  <div style="left:50px">
                                                                                                                      <input id="ClientName" type="text" placeholder="请输入客户名称" class="layui-input">
                                                                                                                  </div>

                                                                                                                  <div class="layui-input-prefix" style="left:100px">
                                                                                                                      客户简称
                                                                                                                  </div>
                                                                                                                  <div style="left:100px">
                                                                                                                      <input id="ClientAName" type="text" placeholder="请输入客户简称" class="layui-input">
                                                                                                                  </div>
                                                                                                              </div>
                                                                                                          </div>

                                                                                                          <div class="layui-form-item">
                                                                                                              <div class="layui-input-group">
                                                                                                                  <div class="layui-input-prefix" style="left:14px">
                                                                                                                      客户英文名称
                                                                                                                  </div>
                                                                                                                  <dic style="left:14px">
                                                                                                                      <input id="ClientEname" type="text" placeholder="请输入客户英文名称" class="layui-input">
                                                                                                                  </dic>

                                                                                                                  <div class="layui-input-prefix" style="left:77px">
                                                                                                                      是否启用
                                                                                                                  </div>
                                                                                                                  <div style="left:77px;width:197px">
                                                                                                                      <select id="IsVaild" lay-filter="testSelect">
                                                                                                                          <option value="-1">是否启用</option>
                                                                                                                          <option value="0">禁用</option>
                                                                                                                          <option value="1">启用</option>
                                                                                                                      </select>
                                                                                                                  </div>

                                                                                                                  <div style="left:150px">
                                                                                                                              <button class="layui-btn" lay-submit lay-filter="demo-table-searchClient">搜索</button>
                                                                                                                  </div>

                                                                                                              </div>
                                                                                                          </div>
                                                                                                      </div>
                                                                                                  </form>
                                                                                                  <table style="left:320px" class="layui-table" id="clientList">
                                                                                                              <thead>
                                                                                                                  <tr>
                                                                                                                      <td><input type="checkbox" id="quanxuan" onclick="xuanzhe()" /></td>
                                                                                                                      <td>客户编号</td>
                                                                                                                      <td>客户名称</td>
                                                                                                                      <td>客户简称</td>
                                                                                                                      <td>客户类型</td>
                                                                                                                      <td>客户电话</td>
                                                                                                                      <td>客户联系人</td>
                                                                                                                      <td>客户联系人电话</td>
                                                                                                                      <td>是否启用</td>
                                                                                                                      <td>操作</td>
                                                                                                                  </tr>
                                                                                                              </thead>
                                                                                                              <tbody id="ClientTable"></tbody>
                                                                                                          </table>
                                                                                                          <div id="demo-laypage-allClient"></div>
                                                                                                       `,
                        success: function () {
                            var pageIndex = 1;
                            var pageSize = 2;


                            $(function () {
                                ShowSupplier(pageIndex, pageSize);
                            })
                            form.on('submit(demo-table-searchClient)', function (data) {
                                ShowSupplier(pageIndex, pageSize);

                                return false; // 阻止默认 form 跳转
                            });

                            // 获取客户编码
                            $('#searchBtn').click(function () {
                                var supplier = $('#clientNo').val();
                                ShowSupplier(pageIndex, pageSize)
                            });
                            // 获取客户名称
                            $('#searchBtn').click(function () {
                                var supplier1 = $('#clientName').val();
                                ShowSupplier(pageIndex, pageSize)
                            });
                            //客户简称
                            $('#searchBtn').click(function () {
                                var supplier2 = $('#clientAName').val();
                                ShowSupplier(pageIndex, pageSize)
                            });
                            // 英文名称
                            $('#searchBtn').click(function () {
                                var supplier2 = $('#clientEname').val();
                                ShowSupplier(pageIndex, pageSize)
                            });
                            //是否启用
                            form.on('select(testSelect)', function (data) {
                                ShowPermission(data.value); // data.value
                            });
                            ShowSupplier(pageIndex, pageSize);

                            //客户管理列表
                            function ShowSupplier(index, size) {
                                var clientNo = $("#clientNo").val() || "";
                                var clientName = $("#clientName").val() || "";
                                var clientAName = $("#clientAName").val() || "";
                                var clientEname = $("#clientEname").val() || "";
                                var isVaild = $("#isVaild").val() || -1;
                                $.ajax({
                                    url: '@ViewBag.FoundationWrite' + '/api/Jocker/ClientManagementList',
                                    data: JSON.stringify({ clientNo: clientNo, clientName: clientName, clientAName: clientAName, clientEname: clientEname, isVaild: isVaild, pageIndex: index, pageSize: size }),
                                    type: "post",
                                    async: false,
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: res => {
                                        var tbody = $("#ClientTable");
                                        tbody.empty();
                                        if (res.data != null) {
                                            $.each(res.data, function () {
                                                tbody.append(`<tr>
                                                                                             <td><input type="checkbox" class="fanxuan"/></td>
                                                                                             <td>${this.clientNo}</td>
                                                                                             <td>${this.clientName}</td>
                                                                                             <td>${this.clientAName}</td>
                                                                                             <td>${this.clientTypeName}</td>
                                                                                             <td>${this.clientPhone}</td>
                                                                                             <td>${this.clientContact1}</td>
                                                                                             <td>${this.clientPhone1}</td>
                                                                                             <td>${this.isVaild === 1 ? '启用' : '禁用'}</td>
                                                                                             <td>
                                                                                                  <a  onclick="AddThis('${this.clientNo}','${this.clientName}')" class="btn btn-link layui-btn-xs">选择</a>
                                                                                             </td>
                                                                                             </tr>`);
                                            });
                                        }
                                        form.render(); // 重新渲染下拉
                                        //完整显示
                                        laypage.render({
                                            elem: 'demo-laypage-allClient', // 元素 id
                                            count: res.totalCount, // 数据总数
                                            curr: index,//当前页
                                            limit: size,//每页几条
                                            limits: [2, 3, 4],
                                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                                            jump: function (obj, first) {
                                                if (!first) {
                                                    ShowSupplier(obj.curr, obj.limit);
                                                }
                                            }
                                        });
                                    }
                                })
                            }
                            function AddThis(val, name) {
                                $("[name='CustomerNo']").val(val);
                                $("[name='Customername']").val(name);
                                form.render();
                                layer.close(layer.index); // 关闭当前最新弹层
                            }
                        }
                    });
                },
                'test-iframe-Manage': function () {
                    layer.open({
                        type: 1,
                        area: 'auto',
                        resize: false,
                        shadeClose: true,
                        title: '',
                        content: `<h2 style="text-align:center">物料产品选择</h2>
                                                                                  <div class="layui-row">
                                                                                      <div class="layui-col-xs6 layui-col-md12">
                                                                                      <form class="layui-form" action="">
                                                                                         <div class="layui-form">
                                                                                             <div class="layui-row layui-col-space16">

                                                                                                 <div class="layui-col-md4">
                                                                                                     <div class="layui-input-wrap">

                                                                                                         <div class="layui-input-group">
                                                                                                             <div class="layui-input-split layui-input-prefix">
                                                                                                                 物料编码
                                                                                                             </div>
                                                                                                             <input type="text" id="productManageNodesMan" autocomplete="off" placeholder="请输入物料编码" lay-affix="clear" class="layui-input">
                                                                                                         </div>
                                                                                                     </div>
                                                                                                 </div>
                                                                                                 <div class="layui-col-md4">
                                                                                                     <div class="layui-input-wrap">

                                                                                                         <div class="layui-input-group">
                                                                                                             <div class="layui-input-split layui-input-prefix">
                                                                                                                 物料名称
                                                                                                             </div>
                                                                                                             <input type="text" id="productManageNamesMan" autocomplete="off" placeholder="请输入物料名称" lay-affix="clear" class="layui-input">
                                                                                                         </div>
                                                                                                     </div>
                                                                                                 </div>
                                                                                                 <!-- 按钮 -->
                                                                                                 <div class="layui-btn-container">
                                                                                                     <button class="layui-btn" id="searchBtn" lay-submit lay-filter="demo2">搜索</button>
                                                                                                 </div>
                                                                                             </div>
                                                                                         </div>
                                                                                      </form>
                                                                                      </div>
                                                                                      <div class="layui-col-xs6 layui-col-md3">
                                                                                      <!-- 树形 -->
                                                                                          <div style="float:left">
                                                                                              <div id="ID-tree-demo"></div>
                                                                                          </div>
                                                                                      </div>
                                                                                      <div class="layui-col-xs12 layui-col-md9">
                                                                                          <table class="layui-table">
                                                                                             <colgroup>
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col width="130">
                                                                                                 <col>
                                                                                             </colgroup>
                                                                                             <thead>
                                                                                                 <tr>
                                                                                                     <th>物料编码</th>
                                                                                                     <th>物料名称</th>
                                                                                                     <th>规格型号</th>
                                                                                                     <th>单位</th>
                                                                                                     <th>物料/产品</th>
                                                                                                     <th>所属分类</th>
                                                                                                     <th>是否启用</th>
                                                                                                     <th>设置安全库存</th>
                                                                                                     <th>创建时间</th>
                                                                                                     <th>操作</th>
                                                                                                 </tr>
                                                                                             </thead>
                                                                                             <tbody id="tbodyMan">
                                                                                             </tbody>
                                                                                         </table>
                                                                                         <div id="demo-laypage-allMan"></div>
                                                                                      </div>
                                                                                  </div>`,
                        success: function () {
                            var pageIndexMant = 1;
                            var pageSizeMant = 3;
                            treeList();
                            Show(pageIndexMant, pageSizeMant);
                            function Show(index, size) {
                                $.post({
                                    url: '@ViewBag.FoundationWrite' + '/api/ProductType/ProductManagesLists',
                                    data: JSON.stringify
                                        ({
                                            pageIndex: index,
                                            pageSize: size,
                                            productManageNodes: $("#productManageNodesMan").val(),
                                            productManageNames: $("#productManageNamesMan").val(),
                                        }),
                                    async: false,
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: res => {
                                        var count = "";
                                        console.log(res.data)
                                        var aa = moment(this.productManageTime).format("YYYY-MM-DD")
                                        $.each(res.data, function () {

                                            count += `<tr>
                                                                                                <td>${this.productManageNode}</td>
                                                                                                <td>${this.productManageName}</td>
                                                                                                <td>${this.productManageNumber}</td>
                                                                                                <td>${this.unites}</td>
                                                                                                <td>${this.productZoo}</td>
                                                                                                <td>${this.productTypeId}</td>
                                                                                                <td>${this.isNo}</td>
                                                                                                <td>${this.inventory}</td>
                                                                                                <td>${aa}</td>
                                                                                                <td><a  onclick="ChoosePro('${this.productManageNode}','${this.productManageName}','${this.productManageNumber}','${this.unites}')" class="btn btn-link layui-btn-xs">选择</a></td>
                                                                                            </tr>
                                                                                            `
                                        })
                                        //pagedCount = res.pagedCount;
                                        //pcount = res.totalCount;
                                        $("#tbodyMan").html(count)
                                        // console.log(res.data)

                                        //var page = Math.ceil(res.totalCount / 5);  //总页数
                                        // 完整显示
                                        laypage.render({
                                            elem: 'demo-laypage-allMan', // 元素 id
                                            count: res.totalCount, // 数据总数
                                            curr: index,//当前页
                                            limit: size,//每页几条
                                            limits: [1, 2, 3],
                                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                                            jump: function (obj, first) {
                                                if (!first) {
                                                    Show(obj.curr, obj.limit);
                                                }
                                            }
                                        });
                                    }
                                })
                            }
                            function treeList() {
                                //var datas = [{ title: '物料产品分类', id: productTypeId, field: 'productTypeName', checked: true, spread: true, children: [{ title: 'B-1-1 可允许跳转', id: 3, field: 'name11', href: '', children: [{ title: 'C-1-1-3', id: 23, field: '', children: [{ title: 'D-1-1-3-1', id: 24, field: '', children: [{ title: 'E-1-1-3-1-1', id: 30, field: '' }, { title: 'E-1-1-3-1-2', id: 31, field: '' }] }] }, { title: 'C-1-1-1', id: 7, field: '', children: [{ title: 'D-1-1-1-1 可允许跳转', id: 15, field: '', href: '' }] }, { title: 'C-1-1-2', id: 8, field: '', children: [{ title: 'D-1-1-2-1', id: 32, field: '' }] }] }, { title: 'B-1-2', id: 4, spread: true, children: [{ title: 'C-1-2-1', id: 9, field: '', disabled: true }, { title: 'C-1-2-2', id: 10, field: '' }] }, { title: 'B-1-3', id: 20, field: '', children: [{ title: 'C-1-3-1', id: 21, field: '' }, { title: 'C-1-3-2', id: 22, field: '' }] }] }, { title: 'A-2', id: 2, field: '', spread: true, children: [{ title: 'B-2-1', id: 5, field: '', spread: true, children: [{ title: 'C-2-1-1', id: 11, field: '' }, { title: 'C-2-1-2', id: 12, field: '' }] }, { title: 'B-2-2', id: 6, field: '', children: [{ title: 'C-2-2-1', id: 13, field: '' }, { title: 'C-2-2-2', id: 14, field: '', disabled: true }] }] }, { title: 'A-3', id: 16, field: '', children: [{ title: 'B-3-1', id: 17, field: '', fixed: true, children: [{ title: 'C-3-1-1', id: 18, field: '' }, { title: 'C-3-1-2', id: 19, field: '' }] }, { title: 'B-3-2', id: 27, field: '', children: [{ title: 'C-3-2-1', id: 28, field: '' }, { title: 'C-3-2-2', id: 29, field: '' }] }] }];
                                $.post({
                                    url: '@ViewBag.FoundationWrite' + "/api/ProductType/TreesList",
                                    data: JSON.stringify({}),
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: d => {
                                        datas = d.data;
                                        console.log(datas);
                                        tree.render({
                                            elem: '#ID-tree-demo',
                                            data: datas,
                                            showCheckbox: false,  // 是否显示复选框
                                            onlyIconControl: true,  // 是否仅允许节点左侧图标控制展开收缩
                                            id: 'demo-id-1',
                                            showLine: false,
                                            spread: false,
                                            isJump: true, // 是否允许点击节点时弹出新窗口跳转
                                            click: function (obj) {
                                                var data = obj.data;  //获取当前点击的节点数据
                                                layer.msg('状态：' + obj.state + '<br>节点数据：' + JSON.stringify(data));
                                            }
                                        });
                                    }
                                })
                            }
                            form.on('submit(demo-table-searchClient)', function (data) {
                                ShowSupplier(pageIndex, pageSize);

                                return false; // 阻止默认 form 跳转
                            });


                        }
                    });
                }

            })

            // 指定开关事件
            form.on('switch(switchTest)', function (data) {
                if (this.checked) {
                    var nowDate = new Date();
                    var times = "MO" + (nowDate.getFullYear() + (nowDate.getMonth() + 1).toString().padStart(2, '0') + nowDate.getDate().toString().padStart(2, '0') +
                        nowDate.getHours().toString().padStart(2, '0') + nowDate.getMinutes().toString().padStart(2, '0') + nowDate.getSeconds().toString().padStart(2, '0'));
                    $("[name='ProductionWorkOrdersNo']").val(times);
                } else {
                    $("[name='ProductionWorkOrdersNo']").val("");
                }
                //重新渲染表单
                form.render();
            });
            // radio 事件
            form.on('radio(demo-radio-filter)', function (data) {
                var elem = data.elem; // 获得 radio 原始 DOM 对象
                var value = elem.value; // 获得 radio 值

                if (value == "客户订单") {
                    $("#thisOrders").append(`<div class="layui-col-md4">
                                                                        <label class="layui-form-label">订单编号</label>
                                                                        <div class="layui-input-inline">
                                                                        <input type="text" name="OrdersNo"  placeholder="请输入" autocomplete="off" class="layui-input">
                                                                        </div>
                                                                    </div>`)
                    $("#thisClient").append(`<div class="layui-form-item layui-col-md6">
                                                                        <label class="layui-form-label">客户编码</label>
                                                                        <div class="layui-input-group">
                                                                        <input type="text" name="CustomerNo" class="layui-input">
                                                                        <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                                                                            <i class="layui-icon layui-icon-search" lay-on="test-iframe-Client"></i>
                                                                        </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="layui-col-md6">
                                                                        <label class="layui-form-label">客户名称</label>
                                                                        <div class="layui-input-inline">
                                                                            <input type="text" name="Customername"  placeholder="" autocomplete="off" class="layui-input" disabled>
                                                                        </div>
                                                                    </div>`)
                    //重新渲染表单
                    form.render();
                } else {
                    $("#thisOrders").empty();
                    $("#thisClient").empty();
                }
            });
            $(function () {
                getTable(1, 2);
            })
            //列表显示
            function getTable(pageIndex, pageSize) {
                let dataObj = {
                    productionWorkOrdersNo: $("#ProductionWorkOrdersNoSe").val(),
                    productionWorkOrdersName: $("#ProductionWorkOrdersNameSe").val(),
                    source: $("[name='SourceSe']:checked").val(),
                    productsNo: $("#ProductsNoSe").val(),
                    productsName: $("#ProductsNameSe").val(),
                    clientNo: $("#ClientNoSe").val(),
                    clientName: $("#ClientNameSe").val(),
                    ticketsType: $("#TicketsTypeSe").val(),
                    demandDate: $("#DemandDateSe").val() || null,
                    pageIndex: pageIndex,
                    pageSize: pageSize
                }
                // 创建表格实例
                var inst = table.render({
                    elem: '#ID-table-demo-search',
                    method: 'POST',
                    contentType: 'application/json',
                    toolbar: '#toolbarDemo',
                    defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
                        title: '提示',
                        layEvent: 'LAYTABLE_TIPS',
                        icon: 'layui-icon-tips',
                        onClick: function (obj) { // 2.9.12+
                            layer.alert('自定义工具栏图标按钮');
                        }
                    }],
                    url: '@ViewBag.FoundationRead' + '/api/WorkOrders/PageProductionList', // 此处为静态模拟数据，实际使用时需换成真实接口
                    where: dataObj,
                    cols: [[
                        { field: 'productionWorkOrdersNo', title: '工单编码', width: 120, sort: true, fixed: true },
                        { field: 'productionWorkOrdersName', title: '工单名称', width: 120 },
                        { field: 'ticketsType', title: '工单类型', width: 100 },
                        { field: 'source', title: '工单来源', width: 100 },
                        { field: 'orderNumber', title: '订单编号', width: 100 },
                        { field: 'productManageNode', title: '产品编号', width: 100 },
                        { field: 'productManageName', title: '产品名称', width: 100 },
                        { field: 'productManageNumber', title: '规格型号', width: 100 },
                        { field: 'unites', title: '单位', width: 80 },
                        { field: 'ticketsNum', title: '工单数量', width: 100 },
                        { field: 'adjustNum', title: '调整数量', width: 100 },
                        { field: 'proNum', title: '以生产数量', width: 100 },
                        { field: 'batchNo', title: '批次号', width: 100 },
                        { field: 'clientNo', title: '客户编码', width: 100 },
                        { field: 'clientName', title: '客户名称', width: 100 },
                        { field: 'demandDates', title: '需求日期', width: 100 },
                        { field: 'state', title: '单据状态', width: 100 },
                        { fixed: 'right', title: '操作', width: 140, minWidth: 140, templet: '#toolDemo' }
                    ]],
                    page: false,
                    height: 310,
                    done: function (res) {
                        var id = this.id;
                        console.log(res);// 你可以在这里检查返回的数据结构是否符合预期
                        // 触发单元格工具事件
                        //分页数据
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            count: res.totalCount, // 数据总数
                            curr: pageIndex,
                            limit: pageSize,
                            limits: [2, 3, 4],
                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                if (!first) {
                                    getTable(obj.curr, obj.limit);
                                }
                            }
                        });
                    }
                });
            }
            // 触发单元格工具事件
            table.on('tool(ID-table-demo-search)', function (obj) { // 双击 toolDouble
                var data = obj.data; // 获得当前行数据
                console.log(data)
                if (obj.event === 'edit') {
                    layer.open({
                        type: 1,
                        area: ['1000px', '700px'],
                        resize: false,
                        shadeClose: true,
                        title: '编辑生产工单',
                        content: `<form class="layui-form" action="">
                                                                                                                                             <div class="layui-form-item">
                                                                                                                                                 <label class="layui-form-label"><span style="color:red">*</span>工单编号</label>
                                                                                                                                                 <div class="layui-input-inline">
                                                                                                                                                      <input width="100px" type="text" name="ProductionWorkOrdersNo" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                                 <div class="layui-input-suffix">
                                                                                                                                                     <div class="layui-input-inline">
                                                                                                                                                        <div class="layui-input-group">
                                                                                                                                                                <label class="layui-form-label">自动生成</label>
                                                                                                                                                        <input type="checkbox" name="open" lay-skin="switch" lay-filter="switchTest" title="ON|OFF">

                                                                                                                                                        </div>
                                                                                                                                                     </div>
                                                                                                                                                 </div>
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item">
                                                                                                                                               <label class="layui-form-label"><span style="color:red">*</span>工单名称</label>
                                                                                                                                                  <div class="layui-input-inline">
                                                                                                                                                      <input type="text" name="ProductionWorkOrdersName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item layui-col-md4">
                                                                                                                                               <label class="layui-form-label"><span style="color:red">*</span>来源类型</label>
                                                                                                                                               <div class="layui-input-block">
                                                                                                                                                   <input type="radio" lay-filter="demo-radio-filter" name="Source" value="客户订单" title="客户订单">
                                                                                                                                                   <input type="radio" lay-filter="demo-radio-filter" name="Source" value="库存备货" title="库存备货">
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-col-md4">
                                                                                                                                                 <label class="layui-form-label">订单编号</label>
                                                                                                                                                 <div class="layui-input-inline">
                                                                                                                                                      <input type="text" name="OrdersNo"  placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                                 </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item layui-col-xs6">
                                                                                                                                               <label class="layui-form-label"><span style="color:red">*</span>工单类型</label>
                                                                                                                                                <div class="layui-input-block">
                                                                                                                                                  <select name="TicketsType" lay-filter="aihao">
                                                                                                                                                    <option value=""></option>
                                                                                                                                                    <option value="自产">自产</option>
                                                                                                                                                    <option value="外协">外协</option>
                                                                                                                                                    <option value="外购">外购</option>
                                                                                                                                                  </select>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                              <div class="layui-form-item layui-col-md6">
                                                                                                                                                <label class="layui-form-label"><span style="color:red">*</span>产品编号</label>
                                                                                                                                                <div class="layui-input-group">
                                                                                                                                                     <input type="text" name="ProductsNo" placeholder="带任意前置和后置内容" class="layui-input">
                                                                                                                                                 <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                                                                                                                                                     <i class="layui-icon layui-icon-search" lay-on="test-iframe-Manage"></i>
                                                                                                                                                 </div>
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                              <div class="layui-col-md6">
                                                                                                                                                <label class="layui-form-label"><span style="color:red">*</span>产品名称</label>
                                                                                                                                                <div class="layui-input-inline">
                                                                                                                                                      <input type="text" name="ProductsName"  placeholder="" autocomplete="off" class="layui-input" disabled>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item layui-col-md6">
                                                                                                                                                <label class="layui-form-label">规格型号</label>
                                                                                                                                                <div class="layui-input-group">
                                                                                                                                                      <input type="text" name="Specification" placeholder="带任意前置和后置内容" class="layui-input" disabled>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                              <div class="layui-col-md6">
                                                                                                                                                <label class="layui-form-label">单位</label>
                                                                                                                                                <div class="layui-input-inline">
                                                                                                                                                   <input type="text" name="Units"  placeholder="个" autocomplete="off" class="layui-input" disabled>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                                  <div class="layui-form-item layui-col-xs4">
                                                                                                                                                  <div class="layui-block">
                                                                                                                                                  <label class="layui-form-label"><span style="color:red">*</span>工单数量</label>
                                                                                                                                                  <div class="layui-input-inline" style="width: 100px;">
                                                                                                                                                     <input type="number" name="TicketsNum" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number">
                                                                                                                                                  </div>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-col-xs4">
                                                                                                                                                 <div class="layui-input-group">
                                                                                                                                                     <div class="layui-input-prefix"><span style="color:red">*</span>需求日期</div>
                                                                                                                                                     <div class="layui-input-wrap">
                                                                                                                                                         <div class="layui-input-prefix">
                                                                                                                                                             <i class="layui-icon layui-icon-date"></i>
                                                                                                                                                         </div>
                                                                                                                                                         <input type="text" name="DemandDate" readonly placeholder="请选择需求日期" class="layui-input demo-table-search-date">
                                                                                                                                                     </div>
                                                                                                                                                 </div>
                                                                                                                                             </div>
                                                                                                                                               <div class="layui-col-xs4">
                                                                                                                                               <label class="layui-form-label">批次号</label>
                                                                                                                                                  <div class="layui-input-inline">
                                                                                                                                                     <input type="text" name="BatchNo"  placeholder="请输入" autocomplete="off" class="layui-input">
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item layui-col-md6">
                                                                                                                                                <label class="layui-form-label">客户编码</label>
                                                                                                                                                <div class="layui-input-group">
                                                                                                                                                <input type="text" name="CustomerNo" class="layui-input">
                                                                                                                                                 <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                                                                                                                                                      <i class="layui-icon layui-icon-search" lay-on="test-iframe-Client"></i>
                                                                                                                                                 </div>
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                              <div class="layui-col-md6">
                                                                                                                                                <label class="layui-form-label">客户名称</label>
                                                                                                                                                <div class="layui-input-inline">
                                                                                                                                                    <input type="text" name="Customername"  placeholder="" autocomplete="off" class="layui-input" disabled>
                                                                                                                                                </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item layui-form-text">
                                                                                                                                               <label class="layui-form-label">备注</label>
                                                                                                                                               <div class="layui-input-block">
                                                                                                                                                   <textarea placeholder="请输入内容" name="Remark" class="layui-textarea"></textarea>
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                             <div class="layui-form-item">
                                                                                                                                               <div class="layui-input-block">
                                                                                                                                                 <button type="submit" class="layui-btn" lay-submit lay-filter="UpdateClick">保存</button>
                                                                                                                                                 <button type="submit" class="layui-btn" lay-submit lay-filter="QueR">确认</button>
                                                                                                                                                 <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                                                                                                                               </div>
                                                                                                                                             </div>
                                                                                                                                          </form>`,
                        success: function () {
                            $.ajax({
                                url: '@ViewBag.FoundationRead' + "/api/WorkOrders/PageProductionBack",
                                data: JSON.stringify({ ProNo: data.productionWorkOrdersNo }),
                                type: "post",
                                dataType: "json",
                                contentType: "application/json",
                                success: function (res) {
                                    console.log(123, res);
                                    if (res.objects != null) {
                                        $("[name='ProductionWorkOrdersNo']").val(res.objects.productionWorkOrdersNo)
                                        $("[name='ProductionWorkOrdersName']").val(res.objects.productionWorkOrdersName)
                                        $("[name='Source'][value='" + res.objects.source.toString() + "']").prop("checked", true)
                                        $("[name='OrdersNo']").val(res.objects.orderNumber)
                                        $("[name='TicketsType']").val(res.objects.ticketsType)
                                        $("[name='ProductsNo']").val(res.objects.productManageNode)
                                        $("[name='ProductsName']").val(res.objects.productManageName)
                                        $("[name='Specification']").val(res.objects.productManageNumber)
                                        $("[name='Units']").val(res.objects.unites)
                                        $("[name='TicketsNum']").val(res.objects.ticketsNum)
                                        $("[name='DemandDate']").val(res.objects.demandDate.toString().substring(0, 10))
                                        $("[name='BatchNo']").val(res.objects.batchNo)
                                        $("[name='CustomerNo']").val(res.objects.clientNo)
                                        $("[name='Customername']").val(res.objects.clientName)
                                        $("[name='Remark']").val(res.objects.remark)
                                        form.render();
                                    }
                                }
                            })
                            // 对弹层中的表单进行初始化渲染
                            // 日期
                            laydate.render({
                                elem: '.demo-table-search-date'
                            });

                            // 表单提交事件
                            form.on('submit(UpdateClick)', function (data) {
                                var field = data.field

                                let obj = {
                                    ProductionWorkOrdersNo: $("[name='ProductionWorkOrdersNo']").val(),
                                    ProductionWorkOrdersName: $("[name='ProductionWorkOrdersName']").val(),
                                    Source: $("[name='Source']:checked").val(),
                                    TicketsType: $("[name='TicketsType']").val(),
                                    OrderNumber: $("[name='OrdersNo']").val(),
                                    ProductsNo: $("[name='ProductsNo']").val(),
                                    TicketsNum: $("[name='TicketsNum']").val(),
                                    Remark: $("[name='Remark']").val(),
                                    DemandDate: $("[name='DemandDate']").val(),
                                    BatchNo: $("[name='BatchNo']").val(),
                                    CustomerNo: $("[name='CustomerNo']").val(),
                                    Pid: 1
                                }
                                console.log(obj)
                                $.ajax({
                                    url: '@ViewBag.FoundationWrite' + "/api/WorkOrder/ProductionCreateOrUpdate",
                                    data: JSON.stringify(obj),
                                    type: "post",
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: function (res) {
                                        console.log(123, res);
                                        var mesg = "编辑";
                                        if (res.code > 0) {
                                            layer.msg(mesg + '成功', {
                                                offset: '6px'
                                            });
                                            getTable(1, 2);
                                        }
                                        else {
                                            alert('提交失败')
                                        }

                                    }
                                })
                                // …
                                return false; // 阻止默认 form 跳转
                            });
                            form.on('submit(QueR)', function (data) {
                                var field = data.field

                                let obj = {
                                    ProductionWorkOrdersNo: $("[name='ProductionWorkOrdersNo']").val(),
                                    ProductionWorkOrdersName: $("[name='ProductionWorkOrdersName']").val(),
                                    Source: $("[name='Source']:checked").val(),
                                    TicketsType: $("[name='TicketsType']").val(),
                                    OrderNumber: $("[name='OrdersNo']").val(),
                                    ProductsNo: $("[name='ProductsNo']").val(),
                                    TicketsNum: $("[name='TicketsNum']").val(),
                                    Remark: $("[name='Remark']").val(),
                                    DemandDate: $("[name='DemandDate']").val(),
                                    BatchNo: $("[name='BatchNo']").val(),
                                    CustomerNo: $("[name='CustomerNo']").val(),
                                    State: 1,
                                    Pid: 1
                                }
                                console.log(obj)
                                $.ajax({
                                    url: '@ViewBag.FoundationWrite' + "/api/WorkOrder/ProductionCreateOrUpdate",
                                    data: JSON.stringify(obj),
                                    type: "post",
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: function (res) {
                                        console.log(123, res);
                                        var mesg = "确认";
                                        if (res.code > 0) {
                                            layer.msg(mesg + '成功', {
                                                offset: '6px'
                                            });
                                            getTable(1, 2);
                                        }
                                        else {
                                            alert('提交失败')
                                        }

                                    }
                                })
                                // …
                                return false; // 阻止默认 form 跳转
                            });
                        }
                    });
                }
                else if (obj.event === 'delect') {
                    layer.confirm('确认删除？', { icon: 3 }, function () {
                        $.ajax({
                            url: '@ViewBag.FoundationWrite' + "/api/WorkOrder/ProductionCreateOrDelete",
                            data: { ProNo: data.productionWorkOrdersNo },
                            type: "get",
                            success: function (res) {
                                console.log(123, res);
                                var mesg = "删除";
                                if (res.code > 0) {
                                    layer.msg(mesg + '成功', {
                                        offset: '6px'
                                    });
                                    getTable(1, 2);
                                }
                                else {
                                    alert('删除失败')
                                }

                            }
                        })
                        // …
                        return false; // 阻止默认 form 跳转
                    }, function () {
                        layer.msg('已取消！');
                    });
                }
                else if (obj.event === 'Preview') {
                    location.href = "@ViewBag.MVCIp" + "/Translation/PreviewView?No=" + data.productionWorkOrdersNo;
                }
            });
            // 日期
            laydate.render({
                elem: '.demo-table-search-date'
            });
            // 搜索提交
            form.on('submit(demo-table-search)', function (data) {
                getTable(1, 2);

                return false; // 阻止默认 form 跳转
            });
            upload.render({
                elem: '.demo-class-accept', // 绑定多个元素
                url: '@ViewBag.FoundationWrite' + "/api/WorkOrder/ImportProduction", // 此处配置你自己的上传接口即可
                accept: 'file', // 普通文件
                done: function (res) {
                    console.log(res);
                    if (res.code > 0) {
                        layer.msg('上传成功');
                        getTable(1, 2);
                    }
                }
            });
        });
    </script>
</body>
</html>